﻿// ------------------------------------------------------------------------------
//  © 2008 OpenUpon™.  All rights reserved.
// ------------------------------------------------------------------------------
using System;
using System.Web.UI;

namespace CastUpon {
	public partial class CommentControl : UserControl {
		private string author;
		private string content;
		private DateTime datePosted;
		private int entityId;
		private string website;

		public DateTime DatePosted {
			get { return this.datePosted; }
			set { this.datePosted = value; }
		}

		public string Author {
			get { return this.author; }
			set {
				this.author = value;
				this.WebsiteHyperLink.Text = this.author;
			}
		}

		public int EntityId {
			get { return this.entityId; }
			set { this.entityId = value; }
		}

		public string Website {
			get { return this.website; }
			set { this.website = value; }
		}

		public string Content {
			get { return this.content; }
			set { this.content = value; }
		}

		protected void Page_PreRender(object sender, EventArgs e) {
			this.WebsiteHyperLink.Enabled = !string.IsNullOrEmpty(this.website);
			this.WebsiteHyperLink.NavigateUrl = this.website;
			this.WebsiteHyperLink.Text = this.author;
			this.CommentAnchorHyperlink.NavigateUrl = String.Format("#comment-{0}", this.entityId);
			this.CommentAnchorHyperlink.Text = this.datePosted.ToString("ddd, MMMM dd \\a\\t hh:mm tt");
			this.CommentAnchor.Name = String.Format("comment-{0}", this.entityId);
			this.ContentLiteral.Text = this.content;
		}
	}
}